package com.mifengs.mall.floor;

import android.text.TextUtils;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.Toast;

import com.chad.library.adapter.base.BaseViewHolder;
import com.chad.library.adapter.base.annotation.ItemProviderTag;
import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.mifengs.mall.R;
import com.mifengs.mall.entity.FloorBean;
import com.mifengs.mall.entity.NoticeBean;
import com.mifengs.mall.util.ToIntentUtil;
import com.mifengs.mall.widget.ADTextView;
import java.util.ArrayList;

/**
 * Created by lihaoqi on 2018/4/20.
 */


@ItemProviderTag(
        viewType = FloorListAdapter.TYPE_SIXTEEN,
        layout = R.layout.item_floor_sixteen
)
public class FloorSixTeenProvider extends BaseItemProvider<FloorBean,BaseViewHolder> {


    @Override
    public void convert(BaseViewHolder helper, final FloorBean data, final int position) {
        ADTextView aDTextView = helper.getView(R.id.adtextView);
        LinearLayout llMoreView = helper.getView(R.id.ll_more);
        ArrayList<NoticeBean> noticeBeans = (ArrayList<NoticeBean>) data.getAdverts().get(0).getNoticeList();
        aDTextView.setTexts(noticeBeans);
        aDTextView.setOnItemClickListener(new ADTextView.OnItemClickListener() {
            @Override
            public void onClick(String url) {
                ToIntentUtil.toCommonIntent(url,mContext);
            }
        });
        llMoreView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String moreUrl = data.getAdverts().get(0).getActionUrl();
                if(!TextUtils.isEmpty(moreUrl))
                ToIntentUtil.toCommonIntent(moreUrl,mContext);
            }
        });
    }

    @Override
    public void onClick(BaseViewHolder helper, FloorBean data, int position) {

    }

    @Override
    public boolean onLongClick(BaseViewHolder helper, FloorBean data, int position) {
        return false;
    }


}
